portableSql

MonthsBetweenDates Portable SQL Function

Syntax

MonthsBetweenDates as N (Date1 as D, Date2 as D)

Arguments

Date1Date

A field or value.

Date2Date

A field or value.

Returns

resultNumeric

Returns the difference in months between two dates

Description

Get the difference in months between two dates.

Discussion

The MonthsBetweenDates function calculates the difference in months between two dates

MonthsBetweenDates() function executed on the Northwind Access database
SELECT FIRST 1 OrderDate, ShippedDate, MonthsBetweenDates(OrderDate, ShippedDate) AS Expr1 FROM Orders
=08/16/1994 12:00:00 00 am|10/16/1994 12:00:00 00 am|2